﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LIB
{
    public class easyDoc
    {
        public  easyDoc()
        {
            docOk = false;
            docMsg = "";
        }

        public bool docOk { set; get; }
        public string docMsg { set; get; }
        public string dbName { set; get; }
        public string dbHost { set; get; }
        public string dbUser { set; get; }
        public string dbPort { set; get; }

        public string nameSpace { set; get; }
        public string outputDir { set; get; }

        public string tblName { set; get; }
        public string tblTitle { set; get; }

        public string tblDbName { set; get; }

        public string subFolder { set; get; }

        public string dbType { set; get; }
        public string docTxt { set; get; }

        public string strNames { set; get; }
        public string strTxts { set; get; }

        public List<easyTableField> list = new List<easyTableField>();
        public int fieldCount { set; get; }

        public string v_table { set; get; }
        /// <summary>
        /// 根据类型单字母得到类型名
        /// </summary>
        /// <param name="ty_alias"></param>
        /// <returns></returns>
        public  string getDbTypeFromAlias(string ty_alias)
        {
            string dbType = "varchar";
            switch (ty_alias)
            {
                case "i":
                    dbType = "int";
                    break;
                case "b":
                    dbType = "tinyint";
                    break;
                case "d":
                    dbType = "datetime";
                    break;
                case "f":
                    dbType = "decimal";
                    break;
                case "c":
                    dbType = "varchar";
                    break;
                case "t":
                    dbType = "text";
                    break;
            }

            return dbType;
        }
        public  string getFieldTypeFromAlias(string ty_alias)
        {

            string dbType = "string";
            switch (ty_alias)
            {
                case "i":
                    dbType = "int";
                    break;
                case "b":
                    dbType = "bool";
                    break;
                case "d":
                    dbType = "DateTime";
                    break;
                case "f":
                    dbType = "decimal";
                    break;
                case "c":
                    dbType = "string ";
                    break;
                case "t":
                    dbType = "string";
                    break;
            }

            return dbType;
        }

        public string getFieldLanguageTypeFromAlias(string ty_alias)
        {

            string dbType = "String";
            switch (ty_alias)
            {
                case "i":
                    dbType = "Int32";
                    break;
                case "d":
                    dbType = "Datetime";
                    break;
                case "f":
                    dbType = "Decimal";
                    break;
                case "c":
                    dbType = "String";
                    break;
                case "t":
                    dbType = "String";
                    break;
            }

            return dbType;
        }

    }


    public class easyTableField
    {
        public string fieldTitle { set; get; }
        public string fieldName { set; get; }

        /// <summary>
        /// 数据库字段类型 varchar datetime decimal(18,2)
        /// </summary>
        public string dbType { set; get; }
        /// <summary>
        /// 编程语言类型 string int 
        /// </summary>
        public string fieldType { set; get; }
        public string LanguagefieldType { set; get; }
        public string dbLength { set; get; }

        public string dbDefaultValue { set; get; }

        /// <summary>
        ///  lq*0 组合属性
        /// </summary>
        public bool notInList { set; get; }
        public bool needQuery { set; get; }
        public bool isMust { set; get; }
        public bool notInForm { set; get; }

        public string formType { set; get; }
        public int formColumns { set; get; }
        public string enmuList { set; get; }


    }
}